<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>生意帮</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css" />
    <style>
        html,
        body {
            background-color: transparent;
            line-height: 1;
        }
        /*轮播图*/

        .lunbotu_one {
            margin: 0 0.5rem;
            border-radius: 4px;
            box-shadow: 1px 1px 10px #ccc;
        }

        .lunbotu_one .swiper-pagination-bullet-active {
            background: #f23030;
        }
        /*好货特卖*/

        .hhtm_box {
            position: relative;
            padding: 0 0.5rem;
            background: #fff;
        }

        .hhtm_box .en_title {
            position: absolute;
            top: 0.75rem;
            left: 0;
            font-size: 1.25rem;
            color: rgba(204, 204, 204, 0.2);
            font-weight: bold;
        }

        .hhtm_box .titles_box {
            padding: 0.75rem 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .hhtm_box .titles_box .left_title span {
            font-weight: bold;
            border: 1px solid #f23030;
            padding: 0.15rem 0.3rem;
            color: #f23030;
            border-radius: 1rem;
        }

        .hhtm_box .titles_box .right_title {
            display: flex;
            align-items: center;
        }

        .hhtm_box .titles_box .right_title img {
            width: 0.3rem;
        }

        .hhtm_box .titles_box .right_title span {
            font-size: 0.7rem;
            color: #6b32ff;
            border: 1px solid #6b32ff;
            padding: 0.15rem 0.3rem;
            border-radius: 1rem;
            margin: 0 0.2rem;
        }

        .hhtm_box .hhtm_lunbotu .swiper-slide {
            position: relative;
        }

        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_title {
            margin: 0.5rem 0;
            font-size: 0.65rem;
            color: #010101;
            height: 1.45rem;
            line-height: 1.2;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_jg {
            font-size: 0.7rem;
            color: #f23030;
            margin-bottom: 0.5rem;
            font-family: cursive;
            font-weight: 600;
        }

        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_yj {
            font-size: 0.5rem;
            color: #999999;
            text-decoration: line-through;
            font-family: cursive;
        }

        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_tip {
            position: absolute;
            top: 0.2rem;
            left: 0.2rem;
        }
        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_tip span{
          margin-right: 0.2rem;
        }
        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_tip span.zp{
          background: #f23030;
          font-size: 0.5rem;
          color: #fff;
          /*padding: 0.1rem 0.2rem;*/
          padding: 0.2rem 0.2rem 0.1rem 0.2rem;
          border-radius: 2px;
        }
        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_tip span.tj{
          background: #ff8000;
          font-size: 0.5rem;
          color: #fff;
          /*padding: 0.1rem 0.2rem;*/
          padding: 0.2rem 0.2rem 0.1rem 0.2rem;
          border-radius: 2px;
        }
        .hhtm_box .hhtm_lunbotu .swiper-slide .hhtm_shop_tip span.xp{
          background: #ff8000;
          font-size: 0.5rem;
          color: #fff;
          /*padding: 0.1rem 0.2rem;*/
          padding: 0.2rem 0.2rem 0.1rem 0.2rem;
          border-radius: 2px;
        }

        .hhtm_box .look_more_btn {
            padding: 0.75rem 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hhtm_box .look_more_btn span {
            color: #ff8000;
            font-size: 0.6rem;
            padding: 0.15rem 0.3rem;
            border: 1px solid #ff8000;
            border-radius: 1rem;
            margin-right: 0.2rem;
        }
        /*今日上新*/

        .bgc_0 {
            background: #fbf9f3;
        }

        .bgc_1 {
            background: #f3f3f4;
        }

        .bgc_2 {
            background: #f3eef4;
        }

        .bgc_3 {
            background: #f0ebe8;
        }

        .jrsx_box {
            position: relative;
            padding: 0;
            background: #fff;
        }

        .jrsx_box .en_title {
            position: absolute;
            top: 0.75rem;
            font-size: 1.25rem;
            color: rgba(204, 204, 204, 0.2);
            font-weight: bold;
        }

        .jrsx_box .titles_box {
            padding: 0.75rem 0.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .jrsx_box .titles_box .left_title span {
            font-weight: bold;
            border: 1px solid #f23030;
            padding: 0.15rem 0.3rem;
            color: #f23030;
            border-radius: 1rem;
        }

        .jrsx_box .titles_box .right_title {
            display: flex;
            align-items: center;
        }

        .jrsx_box .titles_box .right_title img {
            width: 0.3rem;
        }

        .jrsx_box .titles_box .right_title span {
            font-size: 0.7rem;
            color: #ff8000;
            border: 1px solid #ff8000;
            padding: 0.15rem 0.3rem;
            border-radius: 1rem;
            margin: 0 0.2rem;
        }

        .jrsx_box .jrsx_shop_box {
            position: relative;
            float: left;
            width: 50%;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box {
            width: 100%;
            padding: 0.75rem;
            min-height: 7.25rem;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_title {
            font-size: 0.65rem;
            color: #010101;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_jg {
            font-family: cursive;
            font-size: 0.75rem;
            color: #f23030;
            font-weight: 600;
            padding: 0.5rem 0;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_tip{
          font-size: 0;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_tip span.xp {
            background: #ff8000;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_tip span.zp {
            background: #f23030;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
            margin-top: 0.5rem;
        }
        .jrsx_box .jrsx_shop_box .jrsx_shop_list_box .jrsx_shop_tip span.tj {
            background: #ff8000;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
            margin-top: 0.5rem;
        }

        .jrsx_box .jrsx_shop_box .jrsx_shop_img {
            position: absolute;
            bottom: 0.5rem;
            right: 0.5rem;
            height: 45%;
        }
        /*兑换区*/

        .dhq_box {
            position: relative;
            padding: 0;
            background: #fff;
        }

        .dhq_box .en_title {
            position: absolute;
            top: 0.75rem;
            font-size: 1.25rem;
            color: rgba(204, 204, 204, 0.2);
            font-weight: bold;
        }

        .dhq_box .titles_box {
            padding: 0.75rem 0.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .dhq_box .titles_box .left_title span {
            font-weight: bold;
            border: 1px solid #f23030;
            padding: 0.15rem 0.3rem;
            color: #f23030;
            border-radius: 1rem;
        }

        .dhq_box .titles_box .right_title {
            display: flex;
            align-items: center;
        }

        .dhq_box .titles_box .right_title img {
            width: 0.3rem;
        }

        .dhq_box .titles_box .right_title span {
            font-size: 0.7rem;
            color: #ff8000;
            border: 1px solid #ff8000;
            padding: 0.15rem 0.3rem;
            border-radius: 1rem;
            margin: 0 0.2rem;
        }

        .dhq_shop_box {
            background: #f5f5f5;
            padding: 0.5rem 0.2rem 0.3rem 0.2rem;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        .dhq_shop_box .dhq_shop_list_box {
            position: relative;
            width: calc(50% - 0.1rem);
            background: #fff;
            margin-bottom: 0.2rem;
            border-radius: 4px;
            padding-bottom: 0.5rem;
            overflow: hidden;
        }

        .dhq_shop_box .dhq_shop_list_box .dhq_shop_title {
            margin: 0.5rem 0;
            font-size: 0.65rem;
            color: #010101;
            height: 1.45rem;
            line-height: 1.2;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            padding: 0 0.5rem;
        }

        .dhq_shop_box .dhq_shop_list_box .dhq_shop_jg {
            font-size: 0.7rem;
            color: #f23030;
            font-family: cursive;
            font-weight: 600;
            margin-bottom: 0.15rem;
            padding: 0 0.5rem;
        }

        .dhq_shop_box .dhq_shop_list_box .dhq_shop_yj {
            font-family: cursive;
            font-size: 0.5rem;
            text-decoration: line-through;
            color: #999;
            padding: 0 0.5rem;
        }

        .dhq_shop_box .dhq_shop_list_box .dhq_shop_tip {
            position: absolute;
            top: 0.2rem;
            left: 0.2rem;

        }
        .dhq_shop_box .dhq_shop_list_box .dhq_shop_tip span{
          margin-right: 0.2rem;
        }
        .dhq_shop_box .dhq_shop_list_box .dhq_shop_tip span.zp{
          background: #f23030;
          font-size: 0.5rem;
          color: #fff;
          padding: 0.2rem 0.2rem 0.05rem 0.2rem;
          border-radius: 2px;
        }
        .dhq_shop_box .dhq_shop_list_box .dhq_shop_tip span.xp{
          background: #ff8000;
          font-size: 0.5rem;
          color: #fff;
          padding: 0.2rem 0.2rem 0.05rem 0.2rem;
          border-radius: 2px;
        }
        /*精选推荐*/

        .jxtj_box {}

        .jxtj_box .title_img {
            height: auto;
        }

        .jxtj_shop_box {
            background: #f5f5f5;
            padding: 0.3rem 0.2rem 0.1rem 0.2rem;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        .jxtj_shop_box .jxtj_shop_list_box {
            position: relative;
            width: calc(50% - 0.1rem);
            background: #fff;
            margin-bottom: 0.2rem;
            border-radius: 4px;
            padding-bottom: 0.5rem;
            overflow: hidden;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_title {
            margin: 0.5rem 0;
            font-size: 0.65rem;
            color: #010101;
            height: 1.45rem;
            line-height: 1.2;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            padding: 0 0.5rem;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_jg {
            font-size: 0.7rem;
            color: #f23030;
            font-family: cursive;
            font-weight: 600;
            margin-bottom: 0.15rem;
            padding: 0 0.5rem;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_yj {
            font-family: cursive;
            font-size: 0.5rem;
            text-decoration: line-through;
            color: #999;
            padding: 0 0.5rem;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_tip {
            position: absolute;
            top: 0.2rem;
            left: 0.2rem;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_tip span.zp {
            background: #f23030;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
            margin-right: 0.3rem;
        }

        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_tip span.tj {
            background: #ff8000;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
            margin-right: 0.3rem;
        }
        .jxtj_shop_box .jxtj_shop_list_box .jxtj_shop_tip span.xp {
            background: #ff8000;
            font-size: 0.5rem;
            color: #fff;
            padding: 0.2rem 0.2rem 0.05rem 0.2rem;
            border-radius: 2px;
            margin-right: 0.3rem;
        }
    </style>
</head>

<body>

    <div id="app">
        <div class="aui-refresh-content">

            <!-- 轮播图 -->
            <div id="pro1-swiper" class="swiper-container lunbotu_one">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for="(item,index) in banner" :data-id="index" :style="'background:url('+item.pic+') no-repeat center; background-size:cover;height:8.5rem;'"></div>
                </div>
                <div class="swiper-pagination"></div>
            </div>



            <!-- 好火特卖 -->
            <div class="hhtm_box">

                <div class="en_title">SPECIAL</div>

                <div class="titles_box">
                    <div class="left_title">
                        <span>好货特卖</span>
                    </div>
                    <div class="right_title">
                        <img src="../../image/dianxian.png" alt="">
                        <span>好货推荐</span>
                        <img src="../../image/dianxian.png" alt="">
                    </div>
                </div>

                <!-- 好货特卖轮播图 -->

                <div id="pro2-swiper" class="swiper-container hhtm_lunbotu">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide" v-for="item in goods_recommend" @click='openWindow(item.goods_name, item.goods_id)'>
                            <div class="hhtm_shop_img" :style="'background:url('+item.logo_pic+') no-repeat center; background-size:cover;border-radius:4px;'"></div>
                            <div class="hhtm_shop_title">{{item.goods_name}}</div>
                            <div class="hhtm_shop_jg">￥{{item.price}}</div>
                            <div class="hhtm_shop_yj">￥{{item.oprice}}</div>
                            <div class="hhtm_shop_tip"><span class="zp" v-if="item.including_gifts == 1">含赠品</span><span class="tj" v-if="item.is_show == 1">推荐</span><span class="xp" v-if="item.is_new == 1">新品</span></div>
                        </div>
                    </div>
                </div>

                <div class="look_more_btn" @click="openDetail2('hhtm_frm', '好货特卖')"><span>查看更多</span><img src="../../image/more_s.png" alt=""></div>
            </div>


            <div class="line" style="height:0.5rem;background:#f5f5f5;" v-if="goods_today.length > 0"></div>


            <!-- 今日上新 -->
            <div class="jrsx_box clearfix" v-if="goods_today.length > 0">

                <div class="en_title">PRODUCT</div>

                <div class="titles_box">
                    <div class="left_title">
                        <span>今日上新</span>
                    </div>
                    <div class="right_title" @click="openDetail2('today_new', '今日上新')">
                        <span>更多新品</span>
                        <img src="../../image/more_s.png" alt="">
                    </div>
                </div>

                <div class="jrsx_shop_box" @click='openWindow(item.goods_name, item.goods_id)' v-for="(item,index) in goods_today" v-if='index<4'>
                    <div class="jrsx_shop_list_box bgc_0" :class="'bgc_'+index">
                        <div class="jrsx_shop_title">{{item.goods_name}}</div>
                        <div class="jrsx_shop_jg">{{item.price}}元起</div>
                        <div class="jrsx_shop_tip"><span class="xp">新品</span></div>
                        <div class="jrsx_shop_tip"><span class="zp" v-if="item.including_gifts == 1">含赠品</span></div>
                        <div class="jrsx_shop_tip"><span class="tj" v-if="item.is_show == 1">推荐</span></div>
                    </div>
                    <img :src="item.logo_pic" alt="" class="jrsx_shop_img">
                </div>

            </div>


            <div class="line" style="height:0.5rem;background:#f5f5f5;" v-if="exchange_goods.length > 0"></div>

            <!-- 兑换区 -->
            <div class="dhq_box" v-if="exchange_goods.length > 0 && $api.getStorage('token') && $api.getStorage('token') != '' && $api.getStorage('token') != null && $api.getStorage('token') != 'undefined'">

                <div class="en_title">EXCHANGE</div>

                <div class="titles_box">
                    <div class="left_title">
                        <span>兑换区</span>
                    </div>
                    <div class="right_title" @click="openDetail2('exchange', '兑换区')">
                        <span>前往兑换区</span>
                        <img src="../../image/more_s.png" alt="">
                    </div>
                </div>

                <div class="dhq_shop_box">
                    <div class="dhq_shop_list_box" v-for="(item,index) in exchange_goods" v-if="index<4" @click="openConDetail(item.goods_name, item.goods_id)">
                        <div class="dhq_shop_img" :style="'background:url('+item.logo_pic+') no-repeat center; background-size:cover;'"></div>
                        <div class="dhq_shop_title">{{item.goods_name}}</div>
                        <div class="dhq_shop_jg">{{item.price}}兑换币</div>
                        <!-- <div class="dhq_shop_yj">兑换币</div> -->
                        <div class="dhq_shop_tip"><span class="zp"  v-if="item.including_gifts == 1">含赠品</span><span class="xp">新品</span></div>
                    </div>
                </div>

            </div>


            <!-- 精选推荐 -->
            <div class="jxtj_box">

                <div class="title_img">
                    <img src="../../image/tuijian_home.jpg" width="100%" />
                </div>

                <div class="jxtj_shop_box">

                    <div class="jxtj_shop_list_box" v-for="item in goodsList" @click='openWindow(item.goods_name, item.goods_id)'>
                        <div class="jxtj_shop_img" :style="'background:url('+item.logo_pic+') no-repeat center; background-size:cover;'"></div>
                        <div class="jxtj_shop_title">{{item.goods_name}}</div>
                        <div class="jxtj_shop_jg">¥{{item.price}}</div>
                        <div class="jxtj_shop_yj">￥{{item.oprice}}</div>
                        <div class="jxtj_shop_tip"><span class='zp' v-if='item.including_gifts==1'>含赠品</span><span class="tj">推荐</span><span class="xp" v-if='item.is_new==1'>新品</span></div>
                    </div>

                </div>

            </div>


        </div>
    </div>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>
<script type="text/javascript" src="../../script/aui-slide.js"></script>
<script type="text/javascript" src="../../script/aui-lazyload.js"></script>
<script type="text/javascript">
    var vm
    apiready = function() {

        api.showProgress({
            title: '努力加载中...',
            text: '先喝杯茶...',
            modal: false
        });

       vm = new Vue({
            el: '#app',
            data: {
                banner: [], //banner列表
                goods_recommend: [], //推荐列表
                goods_today: [], //今日上新列表
                exchange_goods: [], //兑换商品列表
                page: 1,
                totalpage: 1,
                goodsList: [],
                cate_Id: "",
                exchange: '0.00',
                test: 0
            },
            created: function() {
              var $_this = this;
              if($api.getStorage('token')){
                api.ajax({
                    url: window.Url.Freegive_isReceive,
                    method: 'post',
                    data: {
                        values: {
                          token:$api.getStorage('token')
                        },

                    }
                },function(ret, err){
                    if (ret) {
                        // console.log( JSON.stringify( ret ) );
                        if(ret.re=='1' && ret.data.is_receive=='1'){
                          api.confirm({
                              title: '提示',
                              msg: '你有赠品可以领取',
                              buttons: ['确定', '取消']
                          }, function(ret, err){
                              if( ret.buttonIndex==1 ){
                                 api.openWin({
                                    name: 'theGiftsHeader',
                                    url: '../five_frame/five_frame_header2.html',
                                    pageParam: {
                                      type:'我的赠品',
                                      name:'theGifts'
                                    }
                                });
                              }
                          });
                        }
                    } else {
                        alert( JSON.stringify( err ) );
                    }
                });
              }
                // alert(cateId)

                $_this.getPurse();
                api.ajax({
                    url: window.Url.Freesource_index,
                    method: 'post',
                    data: {
                        values: {
                            type: 1,
                            token: $api.getStorage('token'),
                            cateId: $_this.cate_Id
                        }
                    }
                }, function(ret, err) {
                    if (ret) {
                        // console.log(JSON.stringify(ret.data))

                        if (ret.re == 1) {
                            $_this.banner = ret.data.banner
                            $_this.goods_recommend = ret.data.goods_recommend
                            $_this.goods_today = ret.data.goods_today
                            $_this.exchange_goods = ret.data.exchange_goods


                            // console.log('首页商品----'+JSON.stringify(ret));


                            $_this.$nextTick(function() {

                                // 轮播图
                                var bannerSwiper = new Swiper('#pro1-swiper', {
                                    autoplay: 3000,
                                    loop: true,
                                    pagination: '.swiper-pagination'
                                })
                                $('#pro1-swiper .swiper-slide').click(function() {
                                    var click_id = $(this).attr('data-id');
                                    console.log(click_id)
                                    var target_id = $_this.banner[click_id].goodsId;
                                    $_this.openWindow('', target_id)
                                })

                                // 好货特卖轮播图

                                var hhtm_swiper = new Swiper('#pro2-swiper', {
                                    slidesPerView: 2.5,
                                    spaceBetween: 10,
                                    freeMode: true
                                })

                                  // 好货特卖商品图片
                                  $('.hhtm_shop_img').height($('.hhtm_shop_img').width())

                                  // 兑换区商品图片
                                  $('.dhq_shop_img').height($('.dhq_shop_img').width())

                                  // 精选推荐商品图片
                                  $('.jxtj_shop_img').height($('.jxtj_shop_img').width())



                            })
                        }

                    } else {
                        api.alert({
                            msg: JSON.stringify(err)
                        });
                    }
                })
                api.ajax({
                    url: window.Url.Freegoods_goodsList,
                    method: 'post',
                    data: {
                        values: {
                            type: 1,
                            page: $_this.page,
                            cateId: $_this.cate_Id

                        }
                    }
                }, function(ret, err) {
                    if (ret) {

                        //  console.log(JSON.stringify(ret.data.sum_page))
                        if (ret.re == 1) {
                            $_this.goodsList = ret.data.list
                            // console.log(JSON.stringify($_this.goodsList))
                            $_this.totalpage = ret.data.sum_page

                            $_this.$nextTick(function() {
                                // 精选推荐商品图片
                                  $('.jxtj_shop_img').height($('.jxtj_shop_img').width())
                            })
                        }
                    } else {
                        api.toast({
                            msg: ret.info,
                            duration: 2000,
                            location: 'bottom'
                        });
                    }
                })
                var scroll = new auiScroll({
                    listen: true, //是否监听滚动高度，开启后将实时返回滚动高度
                    distance: 40 //判断到达底部的距离，isToBottom为true
                }, function(ret) {
                    if (ret.isToBottom) {
                        $_this.page++
                            if ($_this.page > $_this.totalpage) {
                                $_this.page = $_this.totalpage
                                    //console.log($_this.page)
                                return
                            }
                        api.ajax({
                            url: window.Url.Freegoods_goodsList,
                            timeout: 300,
                            method: 'post',
                            data: {
                                values: {
                                    type: 1,
                                    page: $_this.page,
                                    cateId: $_this.cate_Id
                                }
                            }
                        }, function(ret, err) {
                            if (ret) {
                                if (ret) {
                                    //console.log(JSON.stringify(ret))
                                    if (ret.re == 1) {
                                        $_this.goodsList = $_this.goodsList.concat(ret.data.list)

                                        $_this.$nextTick(function() {

                                            // 好货特卖商品图片
                                            $('.hhtm_shop_img').height($('.hhtm_shop_img').width())

                                            // 兑换区商品图片
                                            $('.dhq_shop_img').height($('.dhq_shop_img').width())

                                            // 精选推荐商品图片
                                            $('.jxtj_shop_img').height($('.jxtj_shop_img').width())

                                        })
                                    }

                                }


                            } else {
                                api.toast({
                                    msg: ret.info,
                                    duration: 2000,
                                    location: 'bottom'
                                });
                            }
                        })
                    }

                })
            },
            mounted: function() {
                var $_this = this;
                api.hideProgress()
                var pullRefresh = new auiPullToRefresh({
                    container: document.querySelector('.aui-refresh-content'),
                    triggerDistance: 100
                }, function(ret) {
                    if (ret.status == "success") {
                        api.ajax({
                            url: window.Url.Freesource_index,
                            method: 'post',
                            data: {
                                values: {
                                    type: 1,
                                    token: $api.getStorage('token'),
                                    cateId: $_this.cate_Id
                                }
                            }
                        }, function(ret, err) {
                            if (ret) {
                                // console.log( JSON.stringify(ret.data))
                                if (ret.re == 1) {
                                    $_this.banner = ret.data.banner
                                    $_this.goods_recommend = ret.data.goods_recommend
                                    $_this.goods_today = ret.data.goods_today
                                    $_this.exchange_goods = ret.data.exchange_goods
                                    $_this.$nextTick(function() {

                                        // 轮播图
                                        var bannerSwiper = new Swiper('#pro1-swiper', {
                                            autoplay: 3000,
                                            loop: true,
                                            pagination: '.swiper-pagination'
                                        })
                                        $('#pro1-swiper .swiper-slide').click(function() {
                                            var click_id = $(this).attr('data-id');
                                            // console.log(click_id)
                                            var target_id = $_this.banner[click_id].goodsId;
                                            $_this.openWindow('', target_id)
                                        })

                                        // 好货特卖轮播图

                                        var hhtm_swiper = new Swiper('#pro2-swiper', {
                                            slidesPerView: 2.5,
                                            spaceBetween: 10,
                                            freeMode: true
                                        })
                                        // 好货特卖商品图片
                                        $('.hhtm_shop_img').height($('.hhtm_shop_img').width())

                                        // 兑换区商品图片
                                        $('.dhq_shop_img').height($('.dhq_shop_img').width())

                                        // 精选推荐商品图片
                                        $('.jxtj_shop_img').height($('.jxtj_shop_img').width())


                                    })
                                }

                            } else {
                                api.toast({
                                    msg: ret.info,
                                    duration: 2000,
                                    location: 'bottom'
                                });
                            }
                        })
                        $_this.page = 1;
                        api.ajax({
                            url: window.Url.Freegoods_goodsList,
                            method: 'post',
                            data: {
                                values: {
                                    type: 1,
                                    page: $_this.page,
                                    cateId: $_this.cate_Id
                                }
                            }
                        }, function(ret, err) {
                            if (ret) {
                                console.log(JSON.stringify(ret.data))

                                if (ret.re == 1) {
                                    $_this.goodsList = ret.data.list
                                    $_this.totalpage = ret.data.sum_page
                                    setTimeout(function() {
                                        pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                                    }, 500)
                                }

                            } else {
                                api.toast({
                                    msg: ret.info,
                                    duration: 2000,
                                    location: 'bottom'
                                });
                            }
                        })

                    }
                });



            },
            methods: {
                openWindow: function(name, id) {
                    // all_open_login(function() {
                    api.openWin({
                        name: 'commodity',
                        url: './commodity.html',
                        pageParam: {
                            name: name,
                            id: id
                        }
                    });
                    // })
                },
                openConDetail: function(name, id) {
                    // all_open_login(function() {
                    api.openWin({
                            name: 'commodity_convert',
                            url: '../one_frame/commodity_convert.html',
                            pageParam: {
                                name: name,
                                id: id
                            }
                        })
                        // })
                },
                openDetail2: function(type, name) {
                    // all_open_login(function() {
                    api.openWin({
                            name: type,
                            url: './one_frame_header.html',
                            pageParam: {
                                type: type,
                                name: name
                            }
                        })
                        // })
                },
                openDetail3: function(type, name) {
                    // all_open_login(function() {
                    api.openWin({
                            name: type,
                            url: './one_frame_header3.html',
                            pageParam: {
                                type: type,
                                name: name
                            }
                        })
                        // })
                },
                getPurse: function() {
                    var $_this = this;
                    if ($api.getStorage('token') && $api.getStorage('token') != "" && $api.getStorage('token') != null && $api.getStorage('token') != 'undefined') {
                        api.ajax({
                            url: window.Url.Freeucenter_withdrawalsData,
                            method: 'post',
                            data: {
                                values: {
                                    token: $api.getStorage('token'),
                                }
                            }
                        }, function(ret, err) {
                            if (ret) {
                                // console.log(JSON.stringify(ret.data))

                                if (ret.re == 1) {
                                    $_this.exchange = Base64.decode(ret.data.exchange).slice(3, -5);
                                    // console.log(JSON.stringify($_this.exchange))

                                } else {
                                    // console.log(JSON.stringify(ret));
                                }

                            } else {
                                api.toast({
                                    msg: ret.info,
                                    duration: 2000,
                                    location: 'bottom'
                                });
                            }
                        })
                    }


                },
                getFreesourceIndex: function(cateId) {
                    var $_this = this;
                    api.ajax({
                        url: window.Url.Freesource_index,
                        method: 'post',
                        data: {
                            values: {
                                type: 1,
                                token: $api.getStorage('token'),
                                cateId: cateId
                            }
                        }
                    }, function(ret, err) {
                        if (ret) {
                            // console.log(JSON.stringify(ret.data))

                            if (ret.re == 1) {

                                $_this.banner = ''
                                $_this.goods_recommend = ''
                                $_this.goods_today = ''
                                $_this.exchange_goods = ''

                                $_this.banner = ret.data.banner
                                $_this.goods_recommend = ret.data.goods_recommend
                                $_this.goods_today = ret.data.goods_today
                                $_this.exchange_goods = ret.data.exchange_goods


                                $_this.$nextTick(function() {

                                    // 轮播图
                                    var bannerSwiper = new Swiper('#pro1-swiper', {
                                        autoplay: 3000,
                                        loop: true,
                                        pagination: '.swiper-pagination'
                                    })
                                    $('#pro1-swiper .swiper-slide').click(function() {
                                        var click_id = $(this).attr('data-id');
                                        console.log(click_id)
                                        var target_id = $_this.banner[click_id].goodsId;
                                        $_this.openWindow('', target_id)
                                    })

                                    // 好货特卖轮播图

                                    var hhtm_swiper = new Swiper('#pro2-swiper', {
                                        slidesPerView: 2.5,
                                        spaceBetween: 10,
                                        freeMode: true
                                    })
                                    // 好货特卖商品图片
                                    $('.hhtm_shop_img').height($('.hhtm_shop_img').width())

                                    // 兑换区商品图片
                                    $('.dhq_shop_img').height($('.dhq_shop_img').width())

                                    // 精选推荐商品图片
                                    $('.jxtj_shop_img').height($('.jxtj_shop_img').width())
                                })
                            }

                        } else {
                            api.alert({
                                msg: JSON.stringify(err)
                            });
                        }
                    })

                },
                getFreegoodsGoodsList: function(cateId) {
                    var $_this = this;
                    api.ajax({
                        url: window.Url.Freegoods_goodsList,
                        method: 'post',
                        data: {
                            values: {
                                type: 1,
                                page: $_this.page,
                                cateId: cateId
                            }
                        }
                    }, function(ret, err) {
                        if (ret) {
                            // console.log(JSON.stringify(ret.data))
                            if (ret.re == 1) {
                                $_this.goodsList = ''
                                $_this.goodsList = ret.data.list
                                $_this.totalpage = ret.data.sum_page
                            } else {
                                $_this.goodsList = '';
                                api.toast({
                                    msg: ret.info,
                                    duration: 2000,
                                    location: 'bottom'
                                });

                            }
                        } else {
                            api.toast({
                                msg: ret.info,
                                duration: 2000,
                                location: 'bottom'
                            });
                        }
                    })

                },
            }
        })
    }

    function test(cateId) {
        vm.getFreesourceIndex(cateId);
        vm.getFreegoodsGoodsList(cateId);
        vm.cate_Id = cateId;
        // alert(cateId)
    }
</script>

</html>
